function stripcmHtmlTags(s,max){
s=s.replace(/<br.*?>/ig, ' ');
return s.replace(/<.*?>/ig, '').split(/\s+/).slice(0,max-1).join(' ');
}


function showRCommentsAvatar(json){

	var entry = json.feed.entry;

	var str = "<div id=\"rcommentfd\"><table><tbody>";

	var month = [1,2,3,4,5,6,7,8,9,10,11,12];

	var month2 = ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];

	for(var i=0; i < cm_num; i++){
    var avaT = "";
    
     if ("uri" in entry[i].author[0]) {
     var avaUrl = entry[i].author[0].uri;
     var avaName='<a href="' + avaUrl.$t + '"><b>' + entry[i].author[0].name.$t+'</b></a>';
     
    if(avaUrl.$t.match("blogger.com")) {
      var aurl=entry[i].author[0].gd$image.src;      
      if (aurl.indexOf('blogblog.com')!=-1) {var avaT='https://lh6.googleusercontent.com/-cchblzXPp8I/TgNJpMz-aMI/AAAAAAAAB1Q/NAzNcNF-dxk/s50/blogger-nophoto.png';} 
      else {avaT=aurl;} 
    }
        
		else if(avaUrl.$t.match("openid.net")) { avaT = cm_ava['openid'] ;}

		else if(avaUrl.$t.match("livejournal.com")) { avaT = cm_ava['livej'] ;}

		else if(avaUrl.$t.match("wordpress.com")) { avaT = cm_ava['wp'] ;}

		else if(avaUrl.$t.match("typekey.com")) { avaT = cm_ava['typepad'] ;}

		else if(avaUrl.$t.match("aol.com")) { avaT = cm_ava['aim'] ;}

		else { avaT = cm_ava['url'] ;}
    }

		else { 
      avaT = cm_ava['anon'] ;
      var avaName='<b>' + entry[i].author[0].name.$t+'</b>';
      }

		     
    var imgprofile ='<img class="rcav-photo"align="top" src="'+ avaT +'" />';
		str += '<tr>';
		str += '<td width="56" height="56" valign="top">'+imgprofile+'</td>';


		var pdate = entry[i].published.$t;

		var m = parseInt(pdate.substring(5,7));

		for(var j=0; j<month.length;j++){

			if(m==month[j]){

				m = month2[j]; break;

			}

		}  
      
      
     if (entry[i].title.$t=="") {str += '<td valign="top"><div class="rcav-content"><div class="rcav-author">'+avaName+'</div><div class="rcav-sum"><i style="color:#f00;">'+ entry[i].content.$t +'</i> </div></div></td>'; }
      else {
        str += '<td valign="top"><div class="rcav-content"><div class="rcav-author">'+avaName+' - <i><a href="' + entry[i].link[2].href + '">'+ pdate.substring(11,16) + '-' + pdate.substring(8,10) + '/' + pdate.substring(5,7) + '/' + pdate.substring(2,4)+'</a></i></div><div class="rcav-sum">'+ stripcmHtmlTags(entry[i].content.$t,cm_desc)+ ' ... </div></div></td>'; }

		str += '</tr>';

	}

	str = str + '<tbody></table></div>';

	document.write(str);

}

if(ava_mode == "all") {
document.write("<script type=\"text/javascript\" src=\""+homepage+"/feeds/comments/default?max-results="+cm_num+"&alt=json-in-script&callback=showRCommentsAvatar\"><\/script>");
}
if(ava_mode == "single") {
document.write("<script type=\"text/javascript\" src=\""+homepage+"/feeds/"+postID+"/comments/default?max-results="+cm_num+"&alt=json-in-script&callback=showRCommentsAvatar\"><\/script>");
}
